<?php
/*
 * @Author: 白酒煮饭
 * @Date: 2021-04-01 18:35:18
 * @LastEditors: QQ: 1641763174
 * @LastEditTime: 2021-04-01 20:48:34
 * @Description: file content
 */
include './config.php';
//$conn转为全局变量
global $conn;
$appkey = $_GET["appkey"];

if (strlen($appkey) > 30) {
    $sql = "SELECT * FROM `app_list` WHERE `appkey` = '$appkey'";
    $result = $conn->query($sql);
    $all = $result->fetch_assoc();
    $old_count = $all['count'];
    $new_count = $old_count + 1;
    if ($result->num_rows > 0) {
        mysqli_query($conn, "UPDATE `app_list` SET `count` = '$new_count' WHERE `app_list`.`appkey` = '$appkey'");
        print_r(json_encode('{"code":200,"msg":' . $new_count . '}'));
    } else {
        print_r(json_encode('{"code":203,"msg":"appkey不存在请先创建APP"}'));
    }
} else {
    print_r(json_encode('{"code":204,"msg":"appkey错误"}'));
}

$conn->close();
